#ifndef MY_SQLITE3_INCLUDED
#define MY_SQLITE3_INCLUDED

#include "sqlite3.h"
#include <string>

using std::string;

typedef int (*sqlite3cb)(void* relayed_param,int col_num, char** col_val,char** col_name);
    // return 0 ok
    // other abort the execution
    // sqlite3cb will be invoked for each row int col_val

class Mysqlite3
{
public:
    Mysqlite3();
    ~Mysqlite3();

    bool create_open(const string& dbname,bool bmutilthread = true);
        // create a empty sqlite3 db file and open
        // dbname should be utf-8 string
    bool open(const string& dbname);
        // open existed db file
        // dbname should be utf-8 string

    bool exec(const string& cmd, sqlite3cb cb, string& errmsg, void* relayed_param = NULL);
        // if cb returned value is not 0, exec will abort immediately
        // and cb will not be invoked again
    void release();
private:
    Mysqlite3(const Mysqlite3& other);
    Mysqlite3& operator=(const Mysqlite3& other);

private:
    sqlite3* m_conn;
};


#endif






